package compoundDB.core;

import java.util.List;

import compoundDB.database.container.ColumnField;
import compoundDB.database.container.SearchOption;
import compoundDB.database.enumeration.DataType;
import compoundDB.database.enumeration.SearchOptionType;

/**
 * Interface that defines what functions the gui will have access to.
 */
public interface GUIController
{
	/**
	 * Adds a column to the database.
	 * 
	 * @param name
	 *            The name of the column to add.
	 * 
	 * @param dataType
	 *            The DataType of the column to add.
	 */
	void addColumn(String name, DataType dataType);
	
	/**
	 * Adds a user made compound to the database.
	 * 
	 * @param compound
	 *            the compound array to be added.
	 * 
	 * @param names
	 *            The array of names the compound to be added has.
	 */
	void addCompound(Object[] compound, String[] names);
	
	/**
	 * Performs an advanced search using the given filters.
	 * 
	 * @param filters
	 *            Defines what the search is about.
	 */
	void advancedSearch(List<SearchOption> filters);
	
	/**
	 * Adds a column to the database.
	 * 
	 * @param name
	 *            The name of the column to delete.
	 */
	void deleteColumn(String name);
	
	/**
	 * Deletes a compound from the database, including all properties and names associated.
	 * 
	 * @param guid The list of guids of the compounds to delete.
	 */
	void deleteCompound(List<Long> guid);
	
	/**
	 * Changes an existing compound in the database with some user made changes.
	 * 
	 * @param compound
	 *            The compound array to be edited
	 * 
	 * @param names
	 *            The array of names the componud to be edited has.
	 */
	void editCompound(Object[] compound, String[] names);
	
	/**
	 * Will export the compounds with the given GUIDs into the specified file.
	 * 
	 * @param guids
	 *            The array of guids of componuds to export.
	 * 
	 * @param filename
	 *            The file to export the compounds to.
	 */
	void exportCompounds(List<Long> guids, String filename);
	
	/**
	 * Gets teh allowed search options for the column.
	 * 
	 * @param column the column to get search options for.
	 * 
	 * @return The array of allowed search options.
	 */
	SearchOptionType[] getAllowedSearchOptions(String column);
	
	/**
	 * Gets teh allowed search options for the column.
	 * 
	 * @param column the column to get search options for.
	 * 
	 * @return The array of allowed search options.
	 */
	String[] getAllowedSearchOptionsInStrings(String column);
	
	/**
	 * Get the column field by name.
	 * 
	 * @param name The column name to get.
	 * 
	 * @return the ColumnField
	 */
	ColumnField getColumnField(String name);
	
	/**
	 * Gets the generic set of properties for compounds so they can be shown by
	 * the GUI.
	 * 
	 * @return A string array with the properties sorted in the order they go on
	 *         the table (left to right).
	 */
	String[] getColumnTitles();
	
	/**
	 * Gets a compound from the data base
	 * 
	 * @param guid
	 *            The guid of the compound.
	 * @return The compound that was asked for
	 */
	Object[] getCompound(long guid);
	
	/**
	 * Gets an array of names for a compound from the data base
	 * 
	 * @param guid
	 *            The guid of the compound.
	 * @return The names of the compound that was asked for
	 */
	String[] getCompoundNames(long guid);
	
	/**
	 * Gets the number of results contained in the current search result.
	 * 
	 * 
	 * @return The number of results contained in the current search result.
	 */
	int getSearchResultCount();
	
	/**
	 * Gets the specified number of results starting from the specified result.
	 * 
	 * @param resultNumStart
	 *            The position in the results to start getting compounds.
	 * 
	 * @param numResults
	 *            The number of compounds to be returned.
	 * 
	 * @return A double object array. Each single array in the double one is a
	 *         compound. e.g Object[Compound number][Property number of that
	 *         compound];
	 */
	Object[][] getSearchResults(int resultNumStart, int numResults);
	
	/**
	 * Opens the given filename, reads the data from it, and enters it into the
	 * database. This process requires a set dialogue Observer in order for the
	 * user to make decisions about import information.
	 * 
	 * @param filename
	 *            The file to import compounds from.
	 */
	void importCompounds(String filename);
	
	/**
	 * Performs a quick search by compound name on the database. The
	 * GUIController will retain the results, which can be retrieved a 'page' at
	 * a time using getSearchResults(int resultNumStart, int numResults).
	 * 
	 * @param name
	 *            Defines what search is about.
	 */
	void quickSearch(String name);
	
	/**
	 * Adds a column to the database.
	 * 
	 * @param name
	 *            The name of the column to change.
	 * 
	 * @param newName
	 *            The name to change the column to.
	 */
	void renameColumn(String name, String newName);
	
	/**
	 * Sets the generic error display dialog box.
	 * 
	 * @param dialog
	 *            The dialog box to display on errors.
	 */
	void setErrorDialogBox(ErrorUserDialog dialog);
	
	/**
	 * Sets the import user control dialog box.
	 * 
	 * @param dialog
	 *            The dialog box to display on errors.
	 */
	void setImportDialogBox(ImportUserDialog dialog);
	
}
